<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Bai 2.22</title>
</head>

<body>
<?php
	if(isset($_POST['a']) && isset($_POST['b']))
	{
		$soA=$_POST['a'];
		$soB=$_POST['b'];
		$a=abs($soA);
		$b=abs($soB);
		$us = 0; //UCLN
		while ($a * $b !=0 )
		{
			  if ($a >= $b) 
				   $a = $a % $b;
			  else
				   $b = $b % $a;
		}
		$us = $a + $b;
		$bs=($soA*$soB)/$us;
	}
?>
<form id="form1" name="form1" method="post" action="Bai2_22.php">
  <table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr style="text-align: center; color: #C60; font-weight: bold; font-style: italic; font-size: 24px; font-family: Verdana, Geneva, sans-serif;">
      <td colspan="2" bgcolor="#FF9966"><p>ƯỚC SỐ CHUNG LỚN NHẤT <br />
      và BỘI SỐ CHUNG NHỎ NHẤT</p></td>
    </tr>
    <tr>
      <td nowrap="nowrap" bgcolor="#FFCCFF">Nhập A:</td>
      <td nowrap="nowrap" bgcolor="#FFCCFF"><input name="a" type="text" id="a" value="<?php echo $_POST['a'];?>" /></td>
    </tr>
    <tr>
      <td nowrap="nowrap" bgcolor="#FFCCFF">Nhập B:</td>
      <td nowrap="nowrap" bgcolor="#FFCCFF"><input name="b" type="text" id="b" value="<?php echo $_POST['b'];?>" /></td>
    </tr>
    <tr>
      <td nowrap="nowrap" bgcolor="#FFCCFF">USCLN:</td>
      <td nowrap="nowrap" bgcolor="#FFCCFF"><span style="text-align: left">
        <input name="us" type="text" id="us" style="background-color:#FCC; color:#F00; font-weight:bold" value="<?php echo $us;?>" />
      </span></td>
    </tr>
    <tr>
      <td nowrap="nowrap" bgcolor="#FFCCFF">BSCNN:</td>
      <td nowrap="nowrap" bgcolor="#FFCCFF"><span style="text-align: left">
        <input name="bs" type="text" id="bs" style="background-color:#FCC; color:#F00; font-weight:bold" value="<?php echo $bs;?>" />
      </span></td>
    </tr>
    <tr style="text-align: center">
      <td colspan="2" nowrap="nowrap" bgcolor="#FFCCFF"><input style="background-color:#FF9" type="submit" name="submit" id="submit" value="Tìm USCLN và BSCNN" /></td>
    </tr>
  </table>
</form>
</body>
</html>